//
//  WorkCardViewController.m
//  Learn
//
//  Created by 迟建国 on 2024/4/6.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "WorkCardViewController.h"
#import "TextbookChapterDetailModel.h"
#import "HomeRequest.h"

@interface WorkCardViewController ()
@property (nonatomic, strong) UIButton *autoBtn;
@property (nonatomic, strong) UIButton *handBtn;
@property (nonatomic, strong) TextbookQuestionsModel *testModel;

@end

@implementation WorkCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"课后单词表-Star…";
    self.view.backgroundColor = UIColor.whiteColor;
    [self setUI];
    [self loadData];
    // Do any additional setup after loading the view.
}
- (void)loadData {
    [HomeRequest getTextbookTestQuestionsWithId:self.model.versionId type: @"跟读" result:^(TextbookQuestionsModel *model) {
        self.testModel = model;
    }];
    
}

- (void)setUI {
    UILabel *stepL = [[UILabel alloc] init];
    stepL.text = @"6/8";
    stepL.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:16];
    stepL.textColor = rgba(142, 142, 142, 1);
    stepL.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:stepL];
    [stepL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(10);
        make.top.equalTo(self.view.mas_top).offset(10 + NavigationBarHeight);
    }];
    
    UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
    [progressView setProgress:0.6];
    [self.view addSubview:progressView];
    [progressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(48);
        make.right.equalTo(self.view.mas_right).offset(-93);
        make.centerY.equalTo(stepL.mas_centerY);
        make.height.offset(2);
    }];
    
    UIView *typeView = [[UIView alloc] init];
    typeView.backgroundColor = rgba(12, 183, 108, 1);
    typeView.layer.cornerRadius = 11;
    typeView.layer.masksToBounds = YES;
    [self.view addSubview:typeView];
    [typeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(stepL.mas_centerY);
        make.right.equalTo(self.view.mas_right).offset(-10);
        make.width.offset(73);
        make.height.offset(22);
    }];
    
    UIButton *autoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    autoBtn.backgroundColor = UIColor.whiteColor;
    [autoBtn setTitle:@"自动" forState:UIControlStateNormal];
    [autoBtn setTitleColor:rgba(12, 183, 108, 1) forState:UIControlStateNormal];
    autoBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:12];
    autoBtn.layer.cornerRadius = 10;
    autoBtn.layer.masksToBounds = YES;
    [autoBtn bk_whenTapped:^{
        self.autoBtn.backgroundColor = UIColor.whiteColor;
        [self.autoBtn setTitleColor:rgba(12, 183, 108, 1) forState:UIControlStateNormal];
        self.handBtn.backgroundColor = rgba(12, 183, 108, 1);
        [self.handBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    }];
    [typeView addSubview:autoBtn];
    self.autoBtn = autoBtn;
    [autoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(typeView.mas_left);
        make.centerY.equalTo(typeView.mas_centerY);
        make.height.offset(20);
        make.width.offset(36);
    }];
    
    UIButton *handBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    handBtn.backgroundColor = rgba(12, 183, 108, 1);
    [handBtn setTitle:@"手动" forState:UIControlStateNormal];
    [handBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    handBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:12];
    handBtn.layer.cornerRadius = 10;
    handBtn.layer.masksToBounds = YES;
    [handBtn bk_whenTapped:^{
        self.handBtn.backgroundColor = UIColor.whiteColor;
        [self.handBtn setTitleColor:rgba(12, 183, 108, 1) forState:UIControlStateNormal];
        self.autoBtn.backgroundColor = rgba(12, 183, 108, 1);
        [self.autoBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    }];
    [typeView addSubview:handBtn];
    self.handBtn = handBtn;
    [handBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(typeView.mas_right);
        make.centerY.equalTo(typeView.mas_centerY);
        make.height.offset(20);
        make.width.offset(36);
    }];
    
    UIImageView *cardImageView = [[UIImageView alloc] init];
    cardImageView.backgroundColor = UIColor.redColor;
    [self.view addSubview:cardImageView];
    [cardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(28);
        make.right.equalTo(self.view.mas_right).offset(-28);
        make.top.equalTo(typeView.mas_bottom).offset(30);
        make.height.offset(180);
    }];
    
    UILabel *wordL = [[UILabel alloc] init];
    wordL.text = @"class";
    wordL.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:32];
    wordL.textColor = rgba(51, 51, 51, 1);
    wordL.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:wordL];
    [wordL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(cardImageView.mas_bottom).offset(20);
    }];
    
    UILabel *yinbiaoL = [[UILabel alloc] init];
    yinbiaoL.text = @"[kla:s]";
    yinbiaoL.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
    yinbiaoL.textColor = rgba(142, 142, 142, 1);
    yinbiaoL.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:yinbiaoL];
    [yinbiaoL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(wordL.mas_bottom).offset(10);
    }];
    
    UILabel *meanL = [[UILabel alloc] init];
    meanL.text = @"n.同学；班级";
    meanL.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
    meanL.textColor = rgba(142, 142, 142, 1);
    meanL.numberOfLines = 0;
    meanL.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:meanL];
    [meanL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(yinbiaoL.mas_bottom).offset(10);
        make.left.equalTo(self.view.mas_left).offset(15);
        make.right.equalTo(self.view.mas_right).offset(-15);
    }];
    
    UILabel *caseL = [[UILabel alloc] init];
    caseL.text = @"例句\nThe teacher instructed the class to preparefor\na test,\n教师通知这一班学生准备测验";
    caseL.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
    caseL.textColor = rgba(142, 142, 142, 1);
    caseL.numberOfLines = 0;
    caseL.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:caseL];
    [caseL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(meanL.mas_bottom).offset(10);
        make.left.equalTo(self.view.mas_left).offset(15);
        make.right.equalTo(self.view.mas_right).offset(-15);
    }];
    
    UIButton *centerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [centerBtn setImage:[UIImage imageNamed:@"icon_play"] forState:UIControlStateNormal];
//    [centerBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:centerBtn];
    [centerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view.mas_bottom).offset(-48 - SafeAreaBottomHeight);
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.height.offset(52);
    }];
    
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftBtn setImage:[UIImage imageNamed:@"icon_read"] forState:UIControlStateNormal];
//    [rightBtn addTarget:self action:@selector(changeBook) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:leftBtn];
    [leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(56);
        make.centerY.equalTo(centerBtn.mas_centerY);
        make.height.offset(44);
    }];
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setImage:[UIImage imageNamed:@"icon_listen"] forState:UIControlStateNormal];
//    [rightBtn addTarget:self action:@selector(changeBook) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:rightBtn];
    [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(-56);
        make.centerY.equalTo(centerBtn.mas_centerY);
        make.height.offset(44);
    }];
    
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_H - SafeAreaBottomHeight - 28, SCREEN_W, 28)];
    bottomView.backgroundColor = rgba(12, 183, 108, 0.1);
    [self.view addSubview:bottomView];
    
    UIButton *lastBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [lastBtn setTitle:@"上一个" forState:UIControlStateNormal];
    [lastBtn setTitleColor:rgba(12, 183, 108, 1) forState:UIControlStateNormal];
    lastBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:12];
    [lastBtn bk_whenTapped:^{
        
    }];
    [bottomView addSubview:lastBtn];
    [lastBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomView.mas_left).offset(20);
        make.centerY.equalTo(bottomView.mas_centerY);
        make.height.offset(28);
    }];
    
    UIButton *nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [nextBtn setTitle:@"下一个" forState:UIControlStateNormal];
    [nextBtn setTitleColor:rgba(12, 183, 108, 1) forState:UIControlStateNormal];
    nextBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:12];
    [nextBtn bk_whenTapped:^{
        
    }];
    [bottomView addSubview:nextBtn];
    [nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(bottomView.mas_right).offset(-20);
        make.centerY.equalTo(bottomView.mas_centerY);
        make.height.offset(28);
    }];
    
    
}
@end
